// 要操作到的元素
window.onload = function () {
    let login = document.getElementById('login');
    let register = document.getElementById('register');
    let form_box = document.getElementsByClassName('form-box')[0];
    let register_box = document.getElementsByClassName('register-box')[0];
    let login_box = document.getElementsByClassName('login-box')[0];

//登入框元素获取
    let input_login = document.querySelectorAll(".login-box input")
    let msg_login = document.querySelectorAll(".login-box p")[0]

//注册框元素获取
    let input_register = document.querySelectorAll(".register-box input")

// 去注册按钮点击事件,点击去注册界面,登入的界面隐藏起来，注册界面移除隐藏
    register.addEventListener('click', () => {
        form_box.style.transform = 'translateX(80%)'; //隐藏移除移除界面时平移过渡动画80%
        form_box.style.backgroundImage = "@{resource/img/原神.jpg}";
        login_box.classList.add('hidden'); //隐藏登入界面
        register_box.classList.remove('hidden'); //注册界面取消隐藏
    })
// 去登录按钮点击事件
    login.addEventListener('click', () => {
        form_box.style.transform = 'translateX(0%)';
        form_box.style.backgroundImage = "@{resource/img/风景.jpg}";
        register_box.classList.add('hidden');
        login_box.classList.remove('hidden');
    })

    for (let i = 0; i < input_login.length; i++) {
        //聚焦到登入界面用户名和密码后框提示文本为空
        input_login[i].addEventListener('focus', () => {
            msg_login.innerText = ""
        })


    }
    for (let i = 0; i < input_register.length; i++) {
        //聚焦到注册界面所有框提示文本为空
        input_register[i].addEventListener('focus', () => {
            msg_login.innerText = ""
        })
    }
}
